python获取淘宝服务器时间的代码 您所在的位置:网站首页 京东 服务器时间 python获取淘宝服务器时间的代码

python获取淘宝服务器时间的代码

2023-08-21 10:55| 来源: 网络整理| 查看: 265

虽然但是,这个只能获取到秒,没法到毫秒。我暂时不知道该咋解决

代码 import requests import time while True: class timeTaobao(object): r1 = requests.get(url='http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp', headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36'}) x = eval(r1.text) timeNum = int(x['data']['t']) def funcname(): timeStamp = float(timeTaobao.timeNum/1000) timeArray = time.localtime(timeStamp) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) return otherStyleTime t = timeTaobao.funcname() print(t) 结果

2021-04-20 15:30:04 2021-04-20 15:30:04 2021-04-20 15:30:04 2021-04-20 15:30:04 2021-04-20 15:30:04 2021-04-20 15:30:05 2021-04-20 15:30:05 2021-04-20 15:30:05 2021-04-20 15:30:05 2021-04-20 15:30:05 2021-04-20 15:30:05



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有